@extends('hrs.layouts.app')  
@section('css')


        <link href="{{asset('hrs/plugins/ladda-buttons/css/ladda-themeless.min.css')}}" rel="stylesheet" type="text/css" /> 
  
@endsection         
@section('content')

            <div class="container">
                    @if(session('rs'))
                              <div class="alert alert-{{session('rs')['status']}}">
                                {{ session('rs')['msg'] }}
                              </div>
                    @endif
              
                <div class="row">
                    <div class="col-sm-12">

                        <div class="card-box">
                        
                            <div class="row">
                                <form method="post" action="{{url('/items',$data->id)}}" id="form1">
                            @method('PUT')
                                <div class="col-lg-12">
                       
                            {{ csrf_field()}}    

                                    
                                        <h5 class="text-muted text-uppercase m-t-0 m-b-10"><b>单据信息</b></h5>

                                        <div class="form-group col-md-4">
                                            <label  class="col-md-3">船名<span class="text-danger">*</span></label>
                                            <div class="col-md-9">
                                            <input type="text" class="form-control" placeholder="" name="ship_name" value="{{$data->ship_name}}" required="">
                                        </div>
                                        </div>
                                        <div class="form-group  col-md-4">
                                            <label class="col-md-3">航次<span class="text-danger">*</span></label>
                                            <div class="col-md-9">
                                            <input type="text" class="form-control" placeholder="" name="ship_line" value="{{$data->ship_line}}" required="">
                                            </div>
                                        </div>
                                       
                                            
                                       
                                       

                                       

                                        <div class="form-group  col-md-4">
                                            <label class="col-md-3">提单号<span class="text-danger">*</span></label>
                                            <div class="col-md-9">
                                            <input type="text" class="form-control" placeholder="" name="code" required="" value="{{$data->code}}">
                                            </div>
                                        </div>
                                        <div class="form-group  col-md-4">
                                            <label class="col-md-3">箱型20<span class="text-danger">*</span></label>
                                            <div class="col-md-9">
                                            <input type="text" class="form-control" placeholder="" name="box_20" value="{{$data->box_20}}">
                                            </div>
                                        </div>
                                        <div class="form-group  col-md-4">
                                            <label class="col-md-3">箱型40<span class="text-danger">*</span></label>
                                            <div class="col-md-9">
                                            <input type="text" class="form-control" placeholder="" name="box_40" value="{{$data->box_40}}">
                                            </div>
                                        </div>
                                    <div class="form-group  col-md-12">
                                            <label class="col-md-1">备注</label>
                                            <div class="col-md-11">
                                            <input type="text" class="form-control" placeholder="" name="remark" value="{{$data->remark}}">
                                            </div>
                                        </div>    

                                        <div class="form-group m-b-10 col-md-12">
                 <button type="submit" class="btn w-sm btn-info waves-effect waves-light" >更新</button>
            </div>
                                    
                                </div>
                               </form>     
                            </div>
                            
                            <hr/>
                            <div class="row">
                                <div class="col-lg-12">
                                    
                                        <div class="pull-right">
                                            <button type="button" class="btn btn-danger btn-fee" >添加费用</button>
                                        </div>
                                </div>
                                <div class="col-lg-12">
            
                                    <h5 class="text-muted text-uppercase m-t-0 m-b-10"><b>费用信息</b></h5>
                                        
                                        <div class="table-responsive">
                                <table class="table table-hover table table-actions-bar">
                                    <thead>
                                        <tr>
                                            <th>序号</th>
                                            <th>费目</th>
                                            <th>应收</th>
                                            <th>应收状态</th>
                                            <th>应收关系人</th>
                                            <th>应付</th>
                                            <th>应付状态</th>
                                            <th>应付关系人</th>
                                            <th>备注</th>
                                         
                                            <th style="width: 200px;">操作</th>
                                        </tr>
                                    </thead>

                                    <tbody>
                                        @foreach($data->fee as $k=>$v)
                                        <tr>
                                           <td>{{$k+1}}</td> 
                                            <td>{{$v->fee_name}}</td>
                                            <td>
                                                {{$v->receive_money}}
                                            </td>
                                            <td><span class="label label-{{$v->receive_status_style}}"  title="{{$v->receive_at}}">
                                                {{$v->receive_status_txt}}
                                                </span> 
                                                <select name="receive_status" class="change-stauts" data-type="receive" data-id="{{$v->id}}">
                                                    <option value="">修改</option>
                                                    <option value="1">已收</option>
                                                    <option value="0">未收</option>
                                                </select>
                                            </td>
                                            
                                            <td>{{$v->receive_contacter}}</td>
                                            <td>
                                              {{$v->pay_money}} 
                                            </td>
                                            
                                            <td>

                                                <span class="label label-{{$v->pay_status_style}}"  title="{{$v->pay_at}}">
                                                {{$v->pay_status_txt}}
                                                </span> 
                                                <select name="pay_status" class="change-stauts" data-type="pay" data-id="{{$v->id}}">
                                                    <option value="">修改</option>
                                                    <option value="1">已付</option>
                                                    <option value="0">未付</option>
                                                </select>

                                                

                                            </td>
                                            <td>{{$v->pay_contacter}}</td>
                                            <td>{{$v->fee_remark}}</td>
                                            

                                           
                                            <td>
                    
                    <a href="{{url('itemfees/'.$v->id.'/edit')}}" class="table-action-btn"><i class="md md-edit"></i>
                    </a>
                    <a href="{{url('itemfees',$v->id)}}" data-method="delete" 
  data-token="{{csrf_token()}}" data-confirm="确定删除吗?"><i class="md md-close"></i>
                    </a>
                                            </td>
                                        </tr>
                                        @endforeach

                                        


                                        

                                    </tbody>
                                </table>
                            </div>

                            <hr/>
                            <div class="col-lg-12">
                                    <div class="col-md-3">
                                        <a class="btn btn-primary">费用小计</a>
                                    </div>
                                    <div class="col-md-3">
                    应收合计：<span class="label label-success">{{$type['receive_money']}}</span>
                                    </div>
                                    <div class="col-md-3">    
                                        应付合计：<span class="label label-danger">{{$type['pay_money']}}</span>
                                    </div>
                                </div> 


                            <div class="row fee" style="display: none">
                                <hr/>
                                <form method="post" action="{{url('/itemfees')}}" id="form2">
                                        <div class="form-group m-b-10 col-md-12">
                                            <label>费目<span class="text-danger">*</span></label>
                                            <input type="text" class="form-control" placeholder="" name="fee_name"  value="{{old('fee_name')}}" required="">
                                        </div>
                                         <div class="form-group m-b-10 col-md-3">
                                            <label>应收<span class="text-danger">*</span></label>
                                            <input type="text" class="form-control" placeholder="" name="receive_money" value="{{old('receive_money')}}">
                                        </div>
                                         <div class="form-group m-b-10 col-md-3">
                                            <label>应收关系人<span class="text-danger">*</span></label>
                                            <input type="text" class="form-control" placeholder="" name="receive_contacter" value="{{old('receive_contacter')}}">
                                        </div>
                                         <div class="form-group m-b-10 col-md-3">
                                            <label>应付<span class="text-danger">*</span></label>
                                            <input type="text" class="form-control" placeholder="" name="pay_money" value="{{old('pay_money')}}">
                                        </div>
                                        <div class="form-group m-b-10 col-md-3">
                                            <label>应付关系人<span class="text-danger">*</span></label>
                                            <input type="text" class="form-control" placeholder="" name="pay_contacter" value="{{old('pay_contacter')}}">
                                        </div>
                                        <div class="form-group m-b-10 col-md-3">
                                            <label>备注<span class="text-danger">*</span></label>
                                            <input type="text" class="form-control" placeholder="" name="fee_remark" value="{{old('fee_remark')}}">
                                        </div>
                                      

                             
                                     
        
            <div class="form-group m-b-10 col-md-12">
                 <button type="button" class="btn w-sm btn-info waves-effect waves-light" id="add-fee">添加费用</button>
            </div>
            <input name="item_id" value="{{$data->id}}" type="hidden">
            {{ csrf_field()}} 
            </form> 
        </div>
                             
   
                                </div>
                                    
                            </div>
                           

  
                        
                        
                    </div>
                </div>
 </div>
               

            </div> <!-- end container -->
@endsection        

        
@section('js')
  <!-- Modal-Effect -->
<script src="{{asset('hrs/plugins/ladda-buttons/js/spin.min.js')}}"></script>
<script src="{{asset('hrs/plugins/ladda-buttons/js/ladda.min.js')}}"></script>
<script src="{{asset('hrs/plugins/ladda-buttons/js/ladda.jquery.min.js')}}"></script>
<script src="{{asset('js/sweetalert.min.js')}}"></script>
    <script type="text/javascript">
        $('.change-stauts').on('change',function(){
            var _this = $(this);
            var data = {};
             data.id = _this.data('id');
             data.type = _this.data('type');
             data.status = _this.val();
             var url = "{{url('itemfees/change-status')}}";
             $.get(url,data,function(rs){
                if(rs.status) {
                    window.location.reload();
                } else {
                    alert('操作失败');
                }
             });

        });

        

        $('#add-fee').on('click',function(e){
             e.preventDefault();
            var l = Ladda.create(this);
            l.start();
            $('#form2').submit();        
           
            return false;
        });

        $('.btn-fee').on('click',function(){
            $('.fee').show();
        });

       
    </script>
@endsection

